package com.alibaba.feignclient;

import com.alibaba.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {


    @Override
    public UserFeignClient create(Throwable throwable) {
        throwable.printStackTrace();

        return new UserFeignClient() {
            @Override
            public User getById(Long id) {
                return new User(-1l,"无此用户","用户服务不可用");
            }
        };
    }
}
